// pages/digitalclock/digitalclock.js
const util = require("../../utils/util.js");
Page({
  data: {
    hour:"",
    min:"",
    sec:"",
    dian:"",
    istransform: true,
    isback:true,
    ishead:false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this
    const data = util.formatTime(new Date()).split(' ')[0];
    that.setData({
      title: data
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    let that = this;
    this.setInterval = setInterval(function () {
      const _currentTime = util.formatTime(new Date()).split(" ")[1];
      const hour = _currentTime.split(":")[0];
      const dian = " ：";
      const min = _currentTime.split(":")[1];
      const sec = _currentTime.split(":")[2];
      that.setData({
        hour:hour,
        min:min,
        sec:sec,
        dian:dian
      });
    }, 1000)
  },


  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    clearInterval(this.setInterval)
  },
  
})